Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate namespace names before setting them #225

Merged
merged 2 commits into from
Jan 8, 2024
Merged

Validate namespace names before setting them #225

merged 2 commits into from
Jan 8, 2024

Conversation

hasnain-db
Copy link
Contributor

Validate the namespace name inside Environment::set_namespace

This prevents user error when copying namespace names output from other commands and pulling in e.g. control characters. We saw user confusion with errors like the below when talking to the k8s server:

Got unexpected status 500 Internal Server Error (Other(Ok(Some(Object {"apiVersion": String("v1"), "code": Number(500), "kind": String("Status"), "message": String("net/http: invalid header field value for \"X-Forwarded-Path\""), "metadata": Object {}, "reason": String("InternalError"), "status": String("Failure")}))), 179)

With this change the error message now shows upfront when setting the namespace, e.g.:

[dev-aws-us-west-2] [test-shard-hasnain-lakhani-spark-tls] [none] > namespace foo&
Invalid namespace name. Namespaces must be valid RFC 1123 labels (less than 64 characters, lowercase alphanumeric or '-', and start and end with an alphanumeric character)

@hasnain-db
Copy link
Contributor Author

clippy failures look unrelated to this PR, this PR isn't touching that code. I can fix them in a separate PR

Copy link
Collaborator

@nicklan nicklan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm! thanks!

@nicklan nicklan merged commit 9b8643d into databricks:master Jan 8, 2024
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants